#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

template<typename T>
struct DisplayElement //struct相当于属性都是public的类
{
    void operator ()(const T& Element) const
    {
        cout << Element << endl;
    }
};

int main(int argc, char const *argv[])
{
    vector<int>intArray;
    vector<char>charArray;
    for(int i = 0; i < 10; i++)
    {
        intArray.push_back(i);
    }
    for(char s = 'a'; s < 'k'; s++)
    {
        charArray.push_back(s);
    }
    //lambada迭代器
    for_each(intArray.begin(), intArray.end(), DisplayElement<int>());
    // for_each(charArray.begin(), charArray.end(), DisplayElement<char>());
    //第三个参数使用匿名函数
    // for_each(charArray.begin(), charArray.end(), [](char& Element){cout << Element << endl;});
    for(auto charIterator = charArray.begin(); charIterator != charArray.end(); ++ charIterator)
    {
        cout << *charIterator << endl;
    }
    return 0;
}
